﻿using Citi.Scheduler.Domain;
using System.Collections.Generic;
using System.Linq;

namespace Citi.Scheduler.WebUi.Models
{
    public class LibraryModel : ModelBase<LibraryModel, Library>
    {
        public bool Active { get; set; }
        public string Name { get; set; }
        public List<LibraryVersionModel> LibraryVersions { get; set; }

        public LibraryVersionModel GetLastVersionByType(LibraryType libraryType)
        {
            var last = LibraryVersions.Where(x => x.Type == libraryType && x.Status == Enums.LibraryStatus.Ok).OrderBy(x => x.Date).LastOrDefault();

            return last;
        }
    }
}